# Maintainer: schuay <jakob.gruber@gmail.com>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: stonecrest <stonecrest[at]gmail[dot]com>
# Contributor: Chocobo1 <chocobo1 AT archlinux DOT net>

pkgname=mac
pkgver=10.29
_pkgver="${pkgver//./}"
pkgrel=1
pkgdesc='APE codec and decompressor'
arch=('loong64' 'x86_64')
url='https://www.monkeysaudio.com/index.html'
license=('custom:BSD')
depends=('glibc' 'gcc-libs')
makedepends=('cmake' 'python-html2text')
source=(
  "$pkgname-$pkgver.zip::https://monkeysaudio.com/files/MAC_${_pkgver}_SDK.zip"
  "$pkgname-$pkgver-license.html::https://www.monkeysaudio.com/license.html"
)
sha512sums=('c49cb3d11493cd7f6632ffb4c284e9333a9682d255863d46835b1b4bee2f50798b8d70a61b2a36ba9cb13836533addfcb644c2470613a38a33ddfac4acafd84d'
            '8c6752b9750971eb7bfdd76f5ad4c150b7cccd38d53d6877fd8196c5eefde9ac867634bc89f11c29d00196d7afb5a595bf8ee7a4475d53dc3de366ff405c1bf7')
b2sums=('a5d9375af98d5422ca7e0f19e1b5372e8f00bf91bd5fead51a211efe4b304db20a8c5429a17d84db8a37b7898490c147115a363937ab9b970d3077c6c21be506'
        'ab7f85fa3ade15d4f872ce2443fda1a62ebb0549a7d3041db1fe62ae42ce4645ae4788a79f1b97f8643ec66323a33eaaebe612e3a4ad6bc73fd32f16ad11b9cf')

build() {
  cmake \
    -S . \
    -B build \
    -D CMAKE_BUILD_TYPE='None' \
    -D CMAKE_INSTALL_PREFIX='/usr'

  cmake --build build

  # generate license
  html2text --ignore-links "$pkgname-$pkgver-license.html" \
    | sed -n '/^## License$/,$p' \
    > LICENSE.md
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE.md
}
